﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using GalaSoft.MvvmLight.Views;
using IService.Conversation;
using IService.Login;
using IService.Main;
using IService.Registration;
using Microsoft.Practices.ServiceLocation;
using Service.Conversation;
using Service.Login;
using Service.Main;
using Service.Registration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ViewModel.Conversation;
using ViewModel.Login;
using ViewModel.Main;
using ViewModel.Registration;

namespace ViewModel.Common
{
    public class ViewModelLocator
    {
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            #region 登陆
            SimpleIoc.Default.Register<ILoginService, LoginService>();
            SimpleIoc.Default.Register<LoginViewModel>();
            #endregion

            #region 注册
            SimpleIoc.Default.Register<IRegistrationService, RegistrationService>();
            SimpleIoc.Default.Register<RegistrationViewModel>();
            #endregion

            #region 主界面
            SimpleIoc.Default.Register<IMainService, MainService>();
            SimpleIoc.Default.Register<MainViewModel>();
            #endregion

            #region 聊天界面
            SimpleIoc.Default.Register<IConversationService, ConversationService>();
            SimpleIoc.Default.Register<ConversationViewModel>();
            #endregion
        }
        /// <summary>
        /// 登陆界面ViewModel
        /// </summary>
        public LoginViewModel LoginViewModel
        {
            get
            {
                return ServiceLocator.Current.GetInstance<LoginViewModel>();
            }
        }
        /// <summary>
        /// 注册界面ViewModel
        /// </summary>
        public RegistrationViewModel RegistrationViewModel
        {
            get
            {
                return ServiceLocator.Current.GetInstance<RegistrationViewModel>();
            }
        }
        /// <summary>
        /// 主界面ViewModel
        /// </summary>
        public MainViewModel MainViewModel
        {
            get
            {
                return ServiceLocator.Current.GetInstance<MainViewModel>();
            }
        }
        /// <summary>
        /// 聊天界面ViewModel
        /// </summary>
        public ConversationViewModel ConversationViewModel
        {
            get
            {
                return ServiceLocator.Current.GetInstance<ConversationViewModel>();
            }
        }
        public static void Cleanup()
        {
            // TODO Clear the ViewModels
        }
    }
}
